import requests as req;
from lxml import etree;
import os;



if __name__ == '__main__':

    url = "http://www.goubanjia.com/";
    # UA伪装
    header = {
        "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36",
        "Mobile-User-Agent":"Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Mobile Safari/537.36"
    }

    result = req.post(url=url,headers=header);
    html_text = result.text;
    html_obj = etree.HTML(html_text);

    body = html_obj.xpath('//tbody');
    for item in body:
        tr = body.xpath("./tr");

        tr.xpath("./td[1]");
